Skip to main content

Antivirus

Antivirus scanning functionality is included in Jadu Central. This allows scanning of files using a third-party Antivirus program. Jadu Central can use a range of third-party Antivirus programs, depending on platform and server config.

Available adapters

The following adapters are available by default. In order to use either default adapters, clamd should be installed on the server. clamd is an antivirus daemon that listens to local connections (e.g., Unix sockets) and an antivirus server that listens to network connections (e.g., TCP). The clamdscan client sends data to clamd for scanning.

  • ClamAV: ClamAV is the default antivirus adapter. Using this adapter, Jadu Central will communicate with the ClamAV daemon directly on 127.0.0.1. The following constants should be defined for this adapter:
    • ANTIVIRUS_SCANNER_ENABLED: Whether to use antivirus scanning, should be set to true
    • ANTIVIRUS_SCANNER_NAME: The antivirus program to be used for scanning, should be set to ClamAV
    • ANTIVIRUS_CLAMAV_PORT: Port used for communication with ClamAV daemon, should be set to 3310
  • Clamdscan: When using the Clamdscan adapter, Jadu Central will call clamdscan via PHP’s exec function. It is necessary to remove exec from the list of disabled functions in PHP in config/php-fpm-config_templates/conf.d/20-disable_functions.conf. The following constants should be defined for this adapter:
    • ANTIVIRUS_CLAMDSCAN_LOCATION: The location of clamdscan defined as an absolute path
    • ANTIVIRUS_SCANNER_NAME: The antivirus program to be used for scanning, should be set to Clamdscan
    • ANTIVIRUS_SCANNER_ENABLED: Whether to use antivirus scanning, should be set to true

Using antivirus in custom developments

Once Antivirus has been configured correctly, it can be used as follows:

$avScanner = new Jadu_AntiVirus_Scanner(); $isfileClean = $avScanner->scan(‘/path/to/my/file.txt’);

Where /path/to/my/file.txt is the file to be scanned and $isFileClean is true if no virus was found. If $isFileClean is false, more information can be gained from calling:

$avScanner->getError();